package com.zhangxun.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhangxun.domain.Notice;
import com.zhangxun.service.NoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api("公告管理接口")
@RestController
@RequestMapping("/shop/notice")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;


    @GetMapping("/page")
    @ApiOperation("分页查询公告接口")
    @PreAuthorize("hasAuthority('shop:notice:page')")
    public Page<Notice> noticepPage(Page<Notice> page,Notice notice){
        page = noticeService.selectPage(page,notice);

        return page;
    }
    @GetMapping("topNoticeList")
    @ApiOperation("小程序查询全部公告")
    public ResponseEntity<List<Notice>> topNoticeList(){
        List<Notice> list = noticeService.list(new LambdaQueryWrapper<Notice>()
                .eq(Notice::getStatus, 1));
        return ResponseEntity.ok(list);

    }
}
